package com.bjsdzk.common.constants;


import com.bjsdzk.common.utils.SimpleDateFormatUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeRangeConstants {
    private Date start;
    private Date end;

    public TimeRangeConstants(Date start, Date end) {
        this.start = start;
        this.end = end;
    }

    public TimeRangeConstants(String startTime, String endTime) {
        SimpleDateFormat ymdhmssdf = SimpleDateFormatUtils.getYMDHMSSDF();
        try {
            this.start = ymdhmssdf.parse(startTime);
            this.end = ymdhmssdf.parse(endTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    public TimeRangeConstants(Long timeRangeStart, Long timeRangeEnd) {
        if (timeRangeStart != null) {
            this.start = new Date(timeRangeStart);
        }
        if (timeRangeEnd != null) {
            this.end = new Date(timeRangeEnd);
        }
    }

    public Date getStart() {
        return start;
    }

    public String getStartYMD() {
        return SimpleDateFormatUtils.getYMDSDF().format(this.start);
    }

    public String getStartYMDHHMMSS() {
        return SimpleDateFormatUtils.getYMDHMSSDF().format(this.start);
    }

    public void setStart(Date start) {
        this.start = start;
    }

    public Date getEnd() {
        return end;
    }

    public String getEndYMD() {
        return SimpleDateFormatUtils.getYMDSDF().format(this.end);
    }

    public String getEndYMDHHMMSS() {
        return SimpleDateFormatUtils.getYMDHMSSDF().format(this.end);
    }

    public void setEnd(Date end) {
        this.end = end;
    }
}
